<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>更新管理员信息 - 志愿服务管理系统</title>
    <!-- Bootstrap CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- Font Awesome -->
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
    <style>
        :root {
            --primary-color: #337ab7;
            --hover-color: #286090;
            --bg-gradient: linear-gradient(145deg, var(--primary-color), var(--hover-color));
            --shadow: 0 2px 10px rgba(0,0,0,0.1);
            --transition: all 0.3s ease;
            --border-radius: 10px;
        }

        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
            min-height: 100vh;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 20px;
        }

        .card {
            width: 100%;
            max-width: 500px;
            background: white;
            border-radius: var(--border-radius);
            box-shadow: var(--shadow);
            border: none;
            overflow: hidden;
        }

        .card-header {
            background: var(--bg-gradient);
            color: white;
            padding: 1.5rem;
            border-bottom: none;
            display: flex;
            align-items: center;
            justify-content: space-between;
        }

        .card-header h2 {
            margin: 0;
            font-size: 1.5rem;
            font-weight: 600;
        }

        .card-body {
            padding: 2rem;
        }

        .form-group {
            margin-bottom: 1.5rem;
            position: relative;
        }

        .form-label {
            font-weight: 500;
            color: #495057;
            margin-bottom: 0.5rem;
            display: block;
        }

        .form-control {
            border-radius: 8px;
            padding: 0.75rem 1rem;
            border: 2px solid #e9ecef;
            transition: var(--transition);
        }

        .form-control:focus {
            border-color: var(--primary-color);
            box-shadow: 0 0 0 0.2rem rgba(51, 122, 183, 0.25);
        }

        .form-control[readonly] {
            background-color: #f8f9fa;
            cursor: not-allowed;
        }

        .input-icon {
            position: absolute;
            right: 1rem;
            top: 2.5rem;
            color: #6c757d;
        }

        .btn-primary {
            background: var(--bg-gradient);
            border: none;
            padding: 0.75rem 1.5rem;
            border-radius: 8px;
            font-weight: 500;
            width: 100%;
            transition: var(--transition);
        }

        .btn-primary:hover {
            transform: translateY(-2px);
            box-shadow: var(--shadow);
        }

        .btn-back {
            color: white;
            text-decoration: none;
            display: flex;
            align-items: center;
            gap: 0.5rem;
            transition: var(--transition);
        }

        .btn-back:hover {
            color: rgba(255, 255, 255, 0.8);
            transform: translateX(-5px);
        }

        .password-toggle {
            cursor: pointer;
        }

        .alert {
            border-radius: var(--border-radius);
            margin-bottom: 1rem;
        }

        @media (max-width: 576px) {
            .card {
                margin: 0 10px;
            }

            .card-header {
                padding: 1rem;
            }

            .card-body {
                padding: 1.5rem;
            }
        }
    </style>
</head>
<body>
<div class="card">
    <div class="card-header">
        <a href="#" th:href="@{/adminList}" class="btn-back">
            <i class="fas fa-arrow-left"></i>
            <span>返回列表</span>
        </a>
        <h2><i class="fas fa-user-edit me-2"></i>更新管理员信息</h2>
    </div>

    <div class="card-body">
        <form th:action="@{'/updateAdmin/'+${admin.getId()}}" method="post" id="updateForm">
            <div class="form-group">
                <label for="nickname" class="form-label">昵称</label>
                <input type="text" class="form-control" id="nickname" name="nickname"
                       th:value="${admin.getNickname()}" required
                       placeholder="请输入昵称">
                <i class="fas fa-user input-icon"></i>
            </div>

            <div class="form-group">
                <label for="mobile" class="form-label">手机号</label>
                <input type="text" class="form-control" id="mobile" name="mobile"
                       th:value="${admin.getMobile()}" readonly>
                <i class="fas fa-phone input-icon"></i>
            </div>

            <div class="form-group">
                <label for="password" class="form-label">密码</label>
                <div class="position-relative">
                    <input type="password" class="form-control" id="password" name="password"
                           th:value="${admin.getPassword()}" required
                           placeholder="请输入密码">
                    <i class="fas fa-eye-slash input-icon password-toggle"
                       onclick="togglePassword()"></i>
                </div>
            </div>

            <div class="form-group">
                <label for="role" class="form-label">角色</label>
                <input type="text" class="form-control" id="role" name="role"
                       th:value="${admin.getRole()}" readonly>
                <i class="fas fa-user-shield input-icon"></i>
            </div>

            <button type="submit" class="btn btn-primary">
                <i class="fas fa-save me-2"></i>保存更新
            </button>
        </form>
    </div>
</div>

<!-- Bootstrap Bundle with Popper -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>

<script>
    // 密码显示切换
    function togglePassword() {
        const passwordInput = document.getElementById('password');
        const toggleIcon = document.querySelector('.password-toggle');

        if (passwordInput.type === 'password') {
            passwordInput.type = 'text';
            toggleIcon.classList.remove('fa-eye-slash');
            toggleIcon.classList.add('fa-eye');
        } else {
            passwordInput.type = 'password';
            toggleIcon.classList.remove('fa-eye');
            toggleIcon.classList.add('fa-eye-slash');
        }
    }

    // 表单验证
    document.getElementById('updateForm').addEventListener('submit', function(e) {
        const nickname = document.getElementById('nickname').value;
        const password = document.getElementById('password').value;

        if (!nickname.trim()) {
            e.preventDefault();
            alert('昵称不能为空！');
            return;
        }

        if (!password.trim()) {
            e.preventDefault();
            alert('密码不能为空！');
            return;
        }
    });
</script>
</body>
</html>